//
//  HomeViewController.m
//  iOSDemo
//
//  Created by login on 15-6-29.
//  Copyright (c) 2015年 login. All rights reserved.
//

#import "HomeViewController.h"
#import "ModuleViewController.h"

@interface HomeViewController ()<UITableViewDataSource,UITableViewDelegate>
{
    UITableView *_rootTableView;
    NSMutableArray * rootList;
}
@end

@implementation HomeViewController

- (instancetype)init
{
    self = [super init];
    if (self) {
        
        rootList=[[NSMutableArray alloc] init];
        
        NSTitleDic *dic1=[[NSTitleDic alloc] init];
        dic1.Title=@"基础知识";
        [dic1.MutableDic setObject:@"JavaScriptCoreViewController" forKey:@"JavaScriptCore基础"];
        [dic1.MutableDic setObject:@"OCReflectionViewController" forKey:@"OC反射机制"];
        [dic1.MutableDic setObject:@"OCJsonViewController" forKey:@"OCJson处理"];
        [dic1.MutableDic setObject:@"JSONModelViewController" forKey:@"JSONModel使用"];
        [dic1.MutableDic setObject:@"TestLoadViewController" forKeyedSubscript:@"UI加载顺序"];
        [rootList addObject:dic1];
        
        NSTitleDic *dic11=[[NSTitleDic alloc] init];
        dic11.Title=@"设计模式";
        [dic11.MutableDic setObject:@"SingletonViewControl" forKey:@"单例模式"];
        [rootList addObject:dic11];
        
       

        
        
        NSTitleDic *dic2=[[NSTitleDic alloc] init];
        dic2.Title=@"导航栏";
        [dic2.MutableDic setObject:@"WhereGoViewController" forKeyedSubscript:@"去哪儿导航"];
        [dic2.MutableDic setObject:@"TStyleViewController" forKey:@"T型下拉菜单"];
        [dic2.MutableDic setObject:@"IntroduceViewController" forKey:@"引导页"];
        [rootList addObject:dic2];
        
        NSTitleDic *dic20=[[NSTitleDic alloc] init];
        dic20.Title=@"布局";
        [dic20.MutableDic setObject:@"TestMyLinearLayout1" forKeyedSubscript:@"线性布局－垂直布局"];
        [dic20.MutableDic setObject:@"TestMyRelativeLayout2" forKeyedSubscript:@"相对布局－居中布局"];
        [dic20.MutableDic setObject:@"TestMyFrameLayout3" forKeyedSubscript:@"相对布局－框架布局"];
        [dic20.MutableDic setObject:@"TestMyTableLayout4" forKeyedSubscript:@"相对布局－表格布局"];
        [dic20.MutableDic setObject:@"QtripLayout" forKeyedSubscript:@"线性布局-汽车首页"];

        
        [rootList addObject:dic20];
        
        
        
        NSTitleDic *dic3=[[NSTitleDic alloc] init];
        dic3.Title=@"列表";
        [dic3.MutableDic setObject:@"BeginCityViewController" forKey:@"出发城市"];
        [dic3.MutableDic setObject:@"DestinationViewController" forKey:@"目的城市"];
        [dic3.MutableDic setObject:@"SelectAreaViewController" forKey:@"城市选择"];
        [dic3.MutableDic setObject:@"DataPickerViewController" forKey:@"日期选择"];
        [dic3.MutableDic setObject:@"SelectLineViewController" forKey:@"线路选择"];
        [dic3.MutableDic setObject:@"SelectCarTypeViewController" forKey:@"车型选择"];
        [dic3.MutableDic setObject:@"PickeBrandViewController" forKey:@"品牌选择"];
        [dic3.MutableDic setObject:@"CarTypeListViewController" forKey:@"车型列表"];
        [dic3.MutableDic setObject:@"DestinationAndMapViewController" forKey:@"目的地选择"];
        [dic3.MutableDic setObject:@"BaseTableViewViewController" forKey:@"基本用法"];
        [dic3.MutableDic setObject:@"ExpandTableViewController" forKey:@"可折叠表格"];
        [rootList addObject:dic3];
        
        NSTitleDic *dic4=[[NSTitleDic alloc] init];
        dic4.Title=@"对话框";
        [dic4.MutableDic setObject:@"HomeHelpViewController" forKey:@"帮助中心"];
        [rootList addObject:dic4];
        
        NSTitleDic *dic5=[[NSTitleDic alloc] init];
        dic5.Title=@"动画";
        [dic5.MutableDic  setObject:@"ScrollPicControl" forKey:@"轮播图片"];
        [dic5.MutableDic  setObject:@"SDCycleViewController" forKey:@"轮播图片2"];
        [dic5.MutableDic  setObject:@"LoadingViewController" forKey:@"Loading"];
        [dic5.MutableDic  setObject:@"MoveViewController" forKey:@"基础动画"];
        [rootList addObject:dic5];
        
        NSTitleDic *dic6=[[NSTitleDic alloc] init];
        dic6.Title=@"地图";
        [dic6.MutableDic setValue:@"BaiduMapViewController" forKey:@"百度地图"];
        [dic6.MutableDic  setValue:@"CityLocationViewController" forKey:@"城市定位"];
        [dic6.MutableDic  setValue:@"POISearchViewController" forKey:@"位置搜索"];
        [rootList addObject:dic6];
        
        NSTitleDic *dic7=[[NSTitleDic alloc] init];
        dic7.Title=@"操作系统";
        [dic7.MutableDic setValue:@"LocationAlertControlViewController" forKey:@"系统定位"];
        [dic7.MutableDic setValue:@"UserDefaultViewController" forKey:@"UserDefault"];
        [rootList addObject:dic7];

    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"Home";
    [self initUITableView];
    self.navigationItem.title=@"IOS 框架";
    self.navigationController.navigationBar.barTintColor=DEFAULTCOLOR;
}

- (void)initUITableView
{
    _rootTableView = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain];
    _rootTableView.delegate = self;
    _rootTableView.dataSource = self;
    [self.view addSubview:_rootTableView];
}

#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    //return _rootList.count;
     return rootList.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"cellIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (!cell) {
        
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    
    //cell.textLabel.text = _rootList[indexPath.row];
    NSTitleDic* dic=(NSTitleDic*)rootList[indexPath.row];
    cell.textLabel.text=dic.Title;
    return cell;
}
#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    ModuleViewController *moduleOne = [[ModuleViewController alloc]init];

    NSTitleDic * dic=(NSTitleDic*)rootList[indexPath.row];
    moduleOne.dict = [dic.MutableDic copy];
    moduleOne.title=dic.Title;
    [self.navigationController pushViewController:moduleOne animated:YES];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
